package testing;

import cash_access.Account;
import cash_access.OverdraftException;
import branch_access.Manager;
import application.bank.Account_Impl;
import mware_lib.NameService;
import mware_lib.ObjectBroker;
import mware_lib.StubSkeletonCom;
import Namensdienst.StandAlone_NS;

public class TestFrame_withStandAlone implements Runnable{
	static String acciD;
	
	public static void main(String[] args) {
//		StandAlone_NS ns = new StandAlone_NS("localhost", 2000);
//		Thread thr = new Thread(ns);
//		thr.start();
		
		ObjectBroker brk = ObjectBroker.getBroker("localhost", 2000);
		NameService ns = brk.getNameService();
		Manager m = (Manager) ns.resolve("Boss");
		acciD = m.createAccount("blubber");
		
		
		for (int i = 0; i < 50; i++) {
			new Thread(new TestFrame_withStandAlone() ).start();			
		}
		
	}

	@Override
	public void run() {
		ObjectBroker brk = ObjectBroker.getBroker("localhost", 2000);
		NameService ns = brk.getNameService();
		Account a = (Account) ns.resolve(acciD);
		a.deposit(500);
		try {
			a.withdraw(500);
		} catch (OverdraftException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		a.deposit(0);
		
	}

}
